// ActionScript file
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;


/**
 * 发送HTTPService 
 * @param String url
 * @param Object param
 * @param Function Callback
 * 
 */
public function SendHttpService( url:String, param:Object = null, Callback:Function = null, name:String='' ):void
{
	var httpServiceObj:HTTPService = new HTTPService();
	httpServiceObj.resultFormat = "e4x";
	httpServiceObj.method = "POST";
	httpServiceObj.url = url;
	httpServiceObj.addEventListener(FaultEvent.FAULT, function(event:FaultEvent):void{doFault(event,name)} );
	httpServiceObj.addEventListener(ResultEvent.RESULT, Callback );
	httpServiceObj.send(param);
}

/**
 *  do fault for HTTPService
 */
private function doFault(event:FaultEvent, name:String):void{
	trace(name+' is Fault.');
	trace(event.message);
	//Alert.show(name+' is Fault.');
	//event.target.sent();
	//this.process1.label = name+'加载失败。 '+this.countForLoad;
}


//private function getConfigRPCResult(event:ResultEvent):void
//{
//	trace(event.result);
//	var config:XML = XML(event.result);
//	this.SITENAME = config.siteurl;
//	this.stage_id = config.stage_id;
//	this.border_id = config.border_id;
//	this.jewelry_id = config.jewelry_id;
//	this.calendar_id = config.calendar_id; 
//	mling.setLab('加载配置文件.完成');
//	
//	mling.setLab('读取用户照片');
//	this.SendHttpService(this.url_MyPhotoRPC, null, this.getMyPhotoRPCResult, 'Photo');
//	
//	this.SendHttpService(this.URLGetMenuRPC, {mid:this.stage_id},this.StagesMenuRPCResult, 'StageMenu');
//	this.SendHttpService(this.URLGetMenuRPC, {mid:this.border_id},this.BorderMenuRPCResult, 'borderMenu');
//	this.SendHttpService(this.URLGetMenuRPC, {mid:this.jewelry_id},this.JewelryMenuRPCResult, 'jewelryMenu');
//	this.SendHttpService(this.URLGetMenuRPC, {mid:this.calendar_id},this.CalendarMenuRPCResult, 'calendarMenu');
//	
//	//删除初始化屏幕 x
//    this.initTotal -= 1;
//    trace(this.initTotal);
//	if(this.initTotal == 0){
//		this.removeChild(this.mling);
//	}
//}


/**
 * 读取用户上传的图片
 */
//private function getMyPhotoRPCResult(event:ResultEvent):void{
//	//trace(event.result);
//	var tmp:Array = new Array();
//	MyUploadPhotos.removeAll();
//	for each (var s:XML in event.result.info)
//	{
//		MyUploadPhotos.addItem({name: s.name, urlx: s.urlx,width:s.width, height:s.height, idx:s.idx, thumb:s.thumb});
//	}
//	
//	trace('用户照片加载完毕');
//	mling.setLab('读取用户照片 完成');
//	
//	mling.setLab('读取已完成作品');
//	this.SendHttpService(this.url_MyMakedRPC, null,this.MakedRPCResult, 'Maked');
//	
//	
//	
//	//删除初始化屏幕 y
//    this.initTotal -= 1;
//    trace(this.initTotal);
//	if(this.initTotal == 0){
//		this.removeChild(this.mling);
//	}
//}



//删除我的照片
public function DelMyPhotoRPCResult(e:ResultEvent):void{
	trace('删除照片成功');
	//trace(e.result);
	var data:XML = XML(e.result);
	var d1:String = data.info.result;
	if(d1 == 'success'){
		
	}else if(d1 == 'failure'){
		Alert.show('系统忙，请稍后再试。');
		return;
	}
	//this.SendHttpService(this.url_MyPhotoRPC, null,this.getMyPhotoRPCResult, '读取照片');
}




